package com.titar.robot.ui.main;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.titar.robot.R;
import com.titar.robot.RobotApp;
import com.titar.robot.base.BaseActivity;
import com.titar.robot.ui.control.ControlActivity;
import com.titar.robot.ui.store.StoreActivity;
import com.titar.robot.ui.workspace.WorkSpaceActivity;
import com.titar.robot.utils.ToastUtils;



public class MainActivity extends BaseActivity {

    private ImageView user_iv1;
    private ImageView user_iv2;

    @Override
    protected void onInitWidget(Bundle savedInstanceState) {
        user_iv1 = findViewById(R.id.main_user_iv1);
        user_iv2 = findViewById(R.id.main_user_iv2);


        //glide典型使用案例
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.ic_launcher)
                .error(R.mipmap.ic_launcher)
                .override(400, 400)
                .circleCrop()
                .skipMemoryCache(true)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .diskCacheStrategy(DiskCacheStrategy.DATA)
                .diskCacheStrategy(DiskCacheStrategy.RESOURCE);

        Glide.with(MainActivity.this).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1564568546247&di=7a9ca0920b4f1f44c5978421fd370779&imgtype=0&src=http%3A%2F%2Fimage.biaobaiju.com%2Fuploads%2F20181113%2F11%2F1542080094-WCHtVdfUwp.jpeg")
                .apply(options)
                .into(user_iv1);

        Glide.with(MainActivity.this).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1564568546247&di=7a9ca0920b4f1f44c5978421fd370779&imgtype=0&src=http%3A%2F%2Fimage.biaobaiju.com%2Fuploads%2F20181113%2F11%2F1542080094-WCHtVdfUwp.jpeg")
                .apply(options)
                .into(user_iv2);
    }

    @Override
    protected void onInitListener() {

    }

    @Override
    public int getContentViewId() {
        return R.layout.activity_main;
    }


    public void progressEdit(View view) {
        jump2Activity(WorkSpaceActivity.class);
    }

    public void fictitiousControl(View view) {
        jump2Activity(ControlActivity.class);
    }

    public void materialStore(View view) {
        jump2Activity(StoreActivity.class);
    }

    private float lastPressBackTime = 0;

    @Override
    public void onBackPressed() {
        float pressTime = System.currentTimeMillis();
        if (pressTime - lastPressBackTime < 3000) {
            RobotApp.appExit();
        } else {
            lastPressBackTime = pressTime;
            ToastUtils.showToast("再次点击退出！");
        }

    }
}
